package com.gp.controller;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.gp.common.result.JsonResult;
import com.gp.model.entity.Areas;
import com.gp.service.IAreasService;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 弓成龙
 * @since 2017-11-26
 */
@RestController
@RequestMapping("/areas")
public class AreasController {
  
  @Autowired
  private IAreasService areasService;
  
  /**
   * 查询申请 
   * @param  
   * @return JsonResult
   */
  @RequestMapping("/list")
  public JsonResult list(Page<Areas> page, @RequestParam(value = "isSearch", required = false) Integer isSearch) {
    if(isSearch!=null && isSearch==1) {
      Wrapper<Areas> wapper = new EntityWrapper<>();
      Map<String, Object> condition = page.getCondition();
      wapper.like("mergerName", (String)condition.get("mergerName"));
      page.setCondition(null);
      Page<Areas> page2 = areasService.selectPage(page,wapper);
      page2.setCondition(condition);
      return new JsonResult("检索成功",page2); 
    }else {
       Page<Areas> result = areasService.selectPage(page);
    }
    return new JsonResult("检索成功",page);
  }
}
